<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>symbol</title>
</head>
<body>
    <script>
        //ES6 引入了一种新的原始数据类型 Symbol，表示独一无二的值
        //Js数据类型 usonb  undefined String Object null Boolean Symbol
        //   you so n b 

        //创建 Symbol，无标识
        let s1 = Symbol();
        let s2 = Symbol();
        console.log(s1,s2, s1 == s2);
        // 创建有标识 Symbol
        let s3 = Symbol('atguigu');
        let s4 = Symbol('atguigu');
        console.log(s3,s4,s3 === s4);
       
        // 全局标识缓存创建  Symbol.for 
        let s5 = Symbol.for('尚硅谷');
        let s6 = Symbol.for('尚硅谷');
        console.log(s5,s6, s5 === s6);

        function fn(){
            return Symbol.for('尚硅谷');
        }
        let s7 = fn();
        console.log(s7 === s6);
        //不能进行运算
        console.log(s5 + '5');//Cannot convert a Symbol value to a number
                            //        转化

        
 
    </script>
</body>
</html> 